<template>
  <div>
    <el-dialog title="入库详情" :visible.sync="visible" width="50%" append-to-body>
      <el-table :border="true" :data="warehouseList" ref="select" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column type="index" width="55" align="center" label="序号" />
        <el-table-column label="仓库名称" align="center" prop="warehouseName" />
        <el-table-column label="所属地区" align="center" prop="region" />
        <el-table-column label="负责人" align="center" prop="responsibleUserName" />
        <el-table-column label="备注" align="center" prop="remark" />
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listWarehouse } from "@/api/module/warehouse";
export default {
  name: "warehouse",
  data(){
    return{
      warehouseList:[],
      productList:[],
      visible:false
    }
  },
  created() {
    this.getList()
  },
  methods:{
    show(){
      this.visible=true
    },
    getList() {
      listWarehouse(this.queryParams).then(response => {
        this.warehouseList = response.rows;
        this.total = response.total;
      });
    },
    handleSelectionChange(value){
      if(value.length>0){
          this.productList=value[0]
          if (value.length > 1) {
            this.$refs.select.clearSelection();
            this.$refs.select.toggleRowSelection(value.pop());
          }
      }
    },
    submitForm(){

      this.visible=false
      this.$emit('showWarehouse',this.productList)
      this.$refs.select.clearSelection()
    },
    cancel(){
      this.productList=[]
      this.$refs.select.clearSelection()
      this.visible=false
    }
  }
}
</script>

<style scoped>

</style>
